import logging
import sys

_DEFAULT_LOG_FORMAT: str = '[%(asctime)s]-[%(threadName)s]-[%(name)s.%(filename)s:%(lineno)d] %(levelname)-4s: %(message)s'
_DEFAULT_DATE_FORMAT: str = '%Y-%m-%d %H:%M:%S'
_DEFAULT_LOG_LEVEL: int = logging.INFO
_logger: logging.Logger = logging.Logger('vod')


def init_logger(level: int = _DEFAULT_LOG_LEVEL):
    global _logger
    _handler = logging.StreamHandler(sys.stdout)
    _formatter_ = logging.Formatter(fmt=_DEFAULT_LOG_FORMAT, datefmt=_DEFAULT_DATE_FORMAT)
    _handler.setFormatter(_formatter_)
    _handler.setLevel(level)
    _logger.addHandler(_handler)


def set_logger(logger: logging.Logger):
    global _logger
    _logger = logger


def get_logger() -> logging.Logger:
    return _logger
